<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //indexOf+循环方法
        // let array = [1, 1, '1','1'];
        // const unique = () => {
        //     let res = [];
        //     for(let i = 0 , len = array.length ; i<len ; i++ ){
        //         let current = array[i];
        //         if(res.indexOf(current) === -1){
        //             res.push(array[i]);
        //         }
        //     }
        //     return res;
        // }
        // console.log(unique(array));

        //Set方法
        let array = [1,1,'1','1'];
        const unique = (arr) => [...new Set(arr)]
        console.log(unique(array));

        //map方法
        // let array = [1,1,'2','2'];
        // const unique = (arr) =>{
        //    const seen = new Map()
        //    return  arr.filter((a) => !seen.has(a) && seen.set(a,1))
        // }
        // console.log(unique(array));

    </script>
</body>
</html>